package com.soft.javase.ch10.test.stream;

import java.util.ArrayList;
import java.util.List;

/**
 * @author wangzhisen
 * @Desc TODO
 * @date 2025/5/7
 * 9. 将员工按照工资由高到低排序，显示名字
 */
public class SortEmployeesSalaryDesc {
    public static void main(String[] args) {
        List<Employee> employees = new ArrayList<>();
        employees.add(new Employee("张三", 25, 7500));
        employees.add(new Employee("李四", 30, 8500));
        employees.add(new Employee("王五", 28, 9000));
        employees.add(new Employee("赵六", 35, 7800));

        System.out.println("员工按工资降序排序:");
        employees.stream()
                .sorted((e1, e2) -> (int)(e2.getSalary() - e1.getSalary()))
                .forEach(e -> System.out.println(e.getName() + ": " + e.getSalary()));
    }
}
